output = open("第二周第三课.txt", "w", encoding="utf-8")
content = """


#append(末尾添加元素)
>>> list_1 = ['a', 'b',]
>>> list_1.append('c')
>>> list_1
['a', 'b', 'c']

#+和+=
>>> list_1 = ['a', 'b']
>>> list_2 = ['c']
>>> list_1 = list_1 + list_2
>>> list_1
['a', 'b', 'c']

>>> list_3 = ['ff']
>>> list_1 += list_3
>>> list_1
['a', 'b', 'c', 'ff']

#*和*=
>>> list_1 = ['cc']
>>> list_1 = list_1 * 10
>>> list_1
['cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc']
>>> list_2 = ['dd']
>>> list_2 *= 10
>>> list_2
['dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd']

#insert指定位置添加元素
>>> list_1 = ['1', '2', '3']
>>> list_.insert(1,'b')
>>> list_1
['1', 'b', '2', '3']

#索引取值
>>> list_1 = ['1', '2', '3']
>>> list_1[2]
'3'

#切片
>>>list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
>>> list_1[0:10:2]
[1, 3, 5, 7, 9]
>>> list_1[-1]
20
>>> list_1.index(1)
0

#update
>>> list_1 = ['a', 'b', 'c', 'd', 'e', 'f']
>>> list_1[1] = '00'
>>> list_1
['a', '00', 'c', 'd', 'e', 'f']
>>> list_1[1:3] = "45"
>>> list_1
['a', '4', '5', 'd', 'e', 'f']

#delete
>>> list_1 = ['1', '2', '3']
>>> list_1.pop()
'3'
>>> list_1.clear()
>>> list_1
[]

#排序
>>> list_1 = [1, 2, 3, 4, 5]
>>> list_1 = [5, 6, 1, 9, 10]
>>> list_1.sort()
>>> list_1
[1, 5, 6, 9, 10]

list_2 = [5, 6, 1, 9, 10]
>>> sorted(list_2)
[1, 5, 6, 9, 10]

>>> list_1 = [2, 6, 8, 4, 1]
>>> list_2 = [5, 9, 3, 7]
>>> list_1.reverse()
>>> list_1
[1, 4, 8, 6, 2]


#tuple
>>> tuple_1 = ('a', 'b', 'c', 'd')
>>> tuple_1[0]
'a'
>>> tuple_1.index('c')
2
>>> tuple_1[0:2]
('a', 'b')


#dict
>>> dict_1 = {'a': 1, 'b': 2, 'c': 3}
>>> dict_1['d'] = 4
>>> dict_1
{'a': 1, 'b': 2, 'c': 3, 'd': 4}
>>> dict_2 = {'e': 5}
>>> dict_1.update(dict_2)
>>> dict_1
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
>>> dict_1.setdefault('d', 8)
4
>>> dict_1.setdefault('f', 6)
6
>>> dict_1['b']
2
>>> dict_1.get('g', 7)
7
>>> dict_1.keys()
dict_keys(['a', 'b', 'c', 'd', 'e', 'f'])
>>> dict_1.values()
dict_values([1, 2, 3, 4, 5, 6])
>>> dict_1.items()
dict_items([('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6)])
>>> dict_1['b'] = 24
>>> dict_1
{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6}
>>> dict_1.update({'h': 10})
>>> dict_1
{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'h': 10}
>>> dict_1.pop('c')
3
>>> dict_1.popitem()
('h', 10)


#set
>>> set_1 = set([1, 2, 3])
>>> set_1.add(4)
>>> set_1
{1, 2, 3, 4}
>>> 2 in set_1
True
>>> set_2 = set([5, 6])
>>> set_1.update(set_2)
>>> set_1
{1, 2, 3, 4, 5, 6}
>>> set_3 = set([7])
>>> set_1.union(set_3)
{1, 2, 3, 4, 5, 6, 7}
>>> set_1.discard(3)
>>> set_1
{1, 2, 4, 5, 6}
>>> set_1.remove(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 3
>>> set_1.discard(3)
>>>



"""
output.write(content)
output.close()